package edu.ccut.saturn.manager.dict.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;

public class DictParamListToMap extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		List<SaturnData> dictParamList = (List<SaturnData>)parameterContext.getParameterValue(0);
			
			List<Map<String, String>> result = new ArrayList<Map<String,String>>();
			
			if(dictParamList != null){
				
				for(SaturnData dictParam : dictParamList){
					
					Map<String, String> map = new HashMap<String, String>();
					
					map.put("paramKey", dictParam.getString("code"));
					map.put("paramName",dictParam.getString("value"));
					map.put("paramPiyin", dictParam.getString("pinyin"));
					
					result.add(map);
				}
			}
			
			parameterContext.setParameter(0, result);
		}
	}
